/*页面加载*/
$(document).ready(function () {
    var roleId = $("#roleListBody").find("tr:first").find("td:first").text();
    $("#roleListBody").find("tr:first").attr("class", "text-c success");
    var frameSrc = "/sysmanager/function_list" + "?roleId=" + roleId;
    $("#function_list_iframe", parent.document).attr("src", frameSrc)
});


/*角色-添加*/
function role_add(title, url, w, h) {
    /* layer_show(title,url,w,h);*/
    layer.open({
        type: 2,
        area: [w + 'px', h + 'px'],
        fix: false, //不固定
        title: false,
        shadeClose: true,
        shade: 0.2,
        content: [url, 'no']
    });
}

/*角色-删除按钮*/
function role_del_button(roleId) {
    layer.confirm('您确定要删除吗？', {
        title: false,
        btn: ['确认', '取消'] //按钮
    }, function () {
        role_del(roleId);
    }, function () {
        layer_close();
    });
}

/*角色-删除*/
function role_del(roleId) {
    $.ajax({
        url: "/account/role/del",
        type: "POST",
        datatype: "JSON",
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify({"id": roleId}),
        success: function (data) {
            if (data.success) {
                window.parent.layer.msg("删除成功！", {
                    area: ['200px', '50px'],
                    title: false,
                    time: 1000,
                    offset: '100px'
                });
                window.location.reload(true);
                layer_close();
            } else {
                window.parent.layer.msg(data.cause, {
                    area: ['200px', '50px'],
                    title: false,
                    time: 1000,
                    offset: '100px'
                });
            }
        },
        error: function () {
            window.parent.layer.msg("删除失败！", {
                area: ['200px', '50px'],
                title: false,
                time: 1000,
                offset: '100px'
            });
        }
    });
}
